Skip to content

Add wrapped side-by-side renderer #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hayatogh
Copy link

@hayatogh hayatogh commented Aug 9, 2025

Thank you for creating such a great project and welcoming community! It encouraged me to make my first contribution.

This pull request introduces wrapped side-by-side as the third diff mode. Fixes #99

The changes in this PR are broken down into three commits:

  • Adds colspan to generic block headers for wrapped side-by-side mode.
  • Adds the wrapped side-by-side renderer.
  • Adds tests for the new renderer.

Changes are tested with:

  • npm start and viewing some PRs
  • npm run validate

The wrapped side-by-side diff style requires that corresponding old and new lines have the same height, even when text on only one side wraps.
To accomplish this without using JavaScript, I chose to place the lines on the same row within an HTML table.

Since this approach creates a fundamentally different HTML structure from the current synchronized-scrolling mode,
implementing it as a new, independent renderer was a cleaner and more maintainable solution than modifying the existing code.

I'd appreciate your feedback on this.

This is a preparation commit for a new wrapped side-by-side diff
renderer.

The new diff view uses four-column tables. Adding colspan allows block
headers to span the full width of the table, ensuring they are
formatted correctly.

This change is backward-compatible. Existing templates will not be
affected because the colspan attribute defaults to 1 and is optional.
This commit introduces wrapped side-by-side as the third diff mode.

The wrapped side-by-side style requires that corresponding old and new
lines have the same height, even when only one side of a line wraps.
To achieve this without JavaScript, lines are placed on the same row
within an HTML table.

Because this approach results in a fundamentally different HTML
structure from the current synchronized scrolling mode,
it was implemented as a new, independent renderer.
This commit adds tests for the new wrapped side-by-side renderer.
The tests are based on and adapted from the existing test suite for the
synchronized scroll side-by-side mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow line breaks in side-by-side view
1 participant